package com.lhnstart.learn.bases.collection_.list_;

import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * list 遍历
 *
 * @author lhn
 * @date 2023/10/31 20:18
 * @since 1.0.0
 **/
public class ListFor {

    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("刘备");
        list.add("张三丰");
        list.add("贾宝玉");
        list.add("曹操");
        list.add("刘备");
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println("next = " + next);
        }
        for (Object o : list) {
            System.out.println("o = " + o);
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println("list.get(i) = " + list.get(i));
        }
    }

}